package cn.tedu.charging.device.controller;

import cn.tedu.charging.common.pojo.param.GunStatusUpdateParam;
import cn.tedu.charging.common.pojo.vo.StationInfoVO;
import cn.tedu.charging.common.web.JsonResult;
import cn.tedu.charging.device.service.StationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("/device")
@RestController
@Api(tags = "设备场站相关接口")
public class StationController {

    @Autowired
    private StationService stationService;

    @ApiOperation("获取场站信息")
    @GetMapping("/station/info/{gunId}")
    public JsonResult createStation(@PathVariable("gunId") Integer gunId){
        log.debug("获取场站信息参数: gunId = {}",gunId);
        StationInfoVO vo = new StationInfoVO();
        vo.setOperatorId(1L);
        vo.setStationId(1);
        return JsonResult.ok(vo);
    }

    @ApiOperation("更新枪的状态")
    @PostMapping("/station/gun/status/update")
    public JsonResult updateGunStatusParam(GunStatusUpdateParam gunStatusUpdateParam){
       log.debug("更新枪的状态信息--{}",gunStatusUpdateParam);
        return JsonResult.ok(true);
    }

    @ApiOperation("附近的充电站")
    @GetMapping("/station/near")
    public JsonResult getNearByStation(Double longitude,Double latitude,Double radius){
        log.debug("查询附近充电站-经度:{},维度:{},距离:{}",longitude,latitude,radius);
        List<StationInfoVO> stationInfoVOS = stationService.getNearByStation(longitude,latitude,radius);
        log.debug("stationInfoVOS={}",stationInfoVOS);
        return JsonResult.ok(stationInfoVOS);
    }
}
